const fs = require("fs");

// 读取文件方法
function readFile(filePath) {
  return new Promise((resolve, reject) => {
    fs.readFile(filePath, (err, data) => {
      if (err) reject(err);
      else resolve(data);
    });
  });
}

// 声明一个async函数
async function main() {
  const promisesArr = [
    readFile("./resources/为学.md"),
    readFile("./resources/插秧诗.md"),
    readFile("./resources/观书有感.md")
  ];
  const result = await Promise.all(promisesArr);
  console.log(result.map(item => item.toString().replace("\r\n", "")));
}

main();
